import java.util.LinkedList;
import java.util.Queue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-04-09
 * Time: 15:07
 */
class Node {
    public char val;
    public Node left;
    public Node right;

    public Node(char val) {
        this.val = val;
    }
}

public class Test {
    public static Node createTree() {
        Node A = new Node('A');
        Node B = new Node('B');
        Node C = new Node('C');
        Node D = new Node('D');
        Node E = new Node('E');
        Node F = new Node('F');
        Node G = new Node('G');
        Node H = new Node('H');
        Node I = new Node('I');
        Node II = new Node('l');
        A.left = C;
        A.right = B;
        C.left = D;
        return A;
    }



 public static boolean fun(Node root) {
        if (root == null) {
            return true;
        }
        //判断是否为完全二叉树
        Queue<Node> queue = new LinkedList<>();
        queue.offer(root);
        while (!queue.isEmpty()) {
            Node cur = queue.poll();
            if (cur == null) {
                break;
            }
            queue.offer(cur.left);
            queue.offer(cur.right);
        }
        //

        while (!queue.isEmpty()) {
            Node top = queue.peek();
            if (top != null) {
                return false;
            } else {
                //不为空
                queue.poll();
            }
        }

        return true;
    }

   public static void main(String[] args) {
        Node root = createTree();
        System.out.println(fun(root));
    }

}
